home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / numericalInput.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.9 KB  |  104 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  August 14, 1996
  22. //  Author:         ms
  23. //
  24. //  Description:
  25. //      Process the numerical input.
  26. //
  27. //  Input Arguments:
  28. //      Numerical values (see scmh command for its syntax).
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. global proc numericalInput( string $value )
  35. {
  36.     // If the string is empty then there is nothing to do here
  37.     int $stringLen = `size $value`;
  38.     if ( $stringLen == 0 ) return;
  39.  
  40.     // Define the character used to mean "ignore this entry position"
  41.     //
  42.     string $ignoreEntryChar = ".";
  43.  
  44.     // Tokenize the value string
  45.     //
  46.     string $valueArray[];
  47.     int $numTokens = tokenize ($value, $valueArray);
  48.  
  49.     // Try to build up the proper string now
  50.     //
  51.     string $result;
  52.     string $numbers;
  53.     // scan for command flags
  54.     //
  55.     for ($i = 0; $i < $numTokens; $i++) {
  56.         // Only need to add one flag to the result string
  57.         if ($valueArray[$i] == "-a") {
  58.             $result = (" " + $result + " " + $valueArray[$i]);
  59.             break;
  60.         }
  61.         else if ($valueArray[$i] == "-r") {
  62.             $result = (" " + $result + " " + $valueArray[$i]);
  63.             break;
  64.         }
  65.         else if ($valueArray[$i] == "a") {
  66.             // Put `-` in front of flag or command will complain
  67.             $result = (" " + $result + " -a");
  68.             break;
  69.         }
  70.         else if ($valueArray[$i] == "r") {
  71.             // Put `-` in front of flag or command will complain
  72.             $result = (" " + $result + " -r");
  73.             break;
  74.         }
  75.     }
  76.  
  77.     // scan for numbers
  78.     //
  79.     int $offset = 1;
  80.     for ($i = 0; $i < $numTokens; $i++) {
  81.         if ($valueArray[$i] == $ignoreEntryChar) {
  82.             $result = (" " + $result + " -ignore " + $offset);
  83.             $offset++;
  84.             $numbers = (" " + $numbers + " 0");
  85.         }
  86.         else if ($valueArray[$i] == "-a" || $valueArray[$i] == "a" ) {
  87.         }
  88.         else if ($valueArray[$i] == "-r" || $valueArray[$i] == "r" ) {
  89.         }
  90.         else if ($valueArray[$i] == "") {
  91.         }
  92.         else {
  93.             $numbers = (" " + $numbers + " " + $valueArray[$i]);
  94.             $offset++;
  95.         }
  96.     }
  97.  
  98.     $stringLen = `size $numbers`;
  99.     if ( $stringLen > 0 )
  100.     {
  101.         catch(`eval( "scmh" + $result + $numbers )`);
  102.     }
  103. }
  104.